﻿using DXApplicationTangche.UC.抖音出入库.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.抖音出入库
{
    public partial class Form抖音出库一览 : DevExpress.XtraEditors.XtraForm
    {
        public Form抖音出库一览()
        {
            InitializeComponent();
            List<DouyinStockOutDTO> douyinStockOutDTOs已发运 = new List<DouyinStockOutDTO>();
            douyinStockOutDTOs已发运 = 抖音Service.getDouyinStockOutQueryAll();
            this.gridControl抖音出库一览.DataSource = douyinStockOutDTOs已发运;
            this.gridView抖音出库一览.ExpandAllGroups();
            this.gridView抖音出库一览.RefreshData();
        }

        private void gridView抖音出库一览_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.Column.Name.Equals("gridColumn尺码"))
            {
                if (!String.IsNullOrWhiteSpace(e.DisplayText))
                {
                    try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                }
                else
                {
                    e.DisplayText = "样衣无尺寸定义";
                }
            }
        }

        private void gridView抖音出库明细_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.Column.Name.Equals("gridColumn尺码1"))
            {
                if (!String.IsNullOrWhiteSpace(e.DisplayText))
                {
                    try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                }
                else
                {
                    e.DisplayText = "样衣无尺寸定义";
                }
            }
        }

        private void gridView抖音出库一览_DoubleClick(object sender, EventArgs e)
        {
            //List<DouyinStockOutDTO> douyinStockOutDTOs明细 = new List<DouyinStockOutDTO>();
            //String styleNameCn = this.gridView抖音出库一览.GetRowCellValue(this.gridView抖音出库一览.FocusedRowHandle, "styleNameCn").ToString();
            //String materialCode = this.gridView抖音出库一览.GetRowCellValue(this.gridView抖音出库一览.FocusedRowHandle, "materialCode").ToString();
            //foreach (DouyinStockOutDTO douyinStockOutDTO in this.douyinStockOutDTOs已发运)
            //{
            //    if (douyinStockOutDTO.styleNameCn.Equals(styleNameCn) && douyinStockOutDTO.materialCode.Equals(materialCode))
            //    {
            //        douyinStockOutDTOs明细.Add(douyinStockOutDTO);
            //    }
            //}
            //this.gridControl抖音出库明细.DataSource = douyinStockOutDTOs明细;
            //this.gridView抖音出库明细.RefreshData();
        }

        private void gridView抖音出库一览_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
        {
            string accountQuantity = gridView抖音出库一览.GetRowCellValue(e.RowHandle, "gridColumn2").ToString();
            if (Convert.ToInt32(accountQuantity) < 0)
            {
                e.Appearance.BackColor = Color.Salmon;
            }
            else if (Convert.ToInt32(accountQuantity) > 0)
            {
                e.Appearance.BackColor = Color.Yellow;
            }
            else
            {
                e.Appearance.BackColor = Color.LightGreen;
            }
        }

        private void gridView明细_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            if (e.Column.Name.Equals("gridColumn尺码2"))
            {
                if (!String.IsNullOrWhiteSpace(e.DisplayText))
                {
                    try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                }
                else
                {
                    e.DisplayText = "样衣无尺寸定义";
                }
            }
        }
    }
}
